/**
 * 新增修改完成调用 modalFormOk方法 编辑弹框组件ref定义为modalForm
 * 高级查询按钮调用 superQuery方法  高级查询组件ref定义为superQueryModal
 * data中url定义 list为查询列表  delete为删除单条记录  deleteBatch为批量删除
 */
import { filterObj, showDealBtn } from '@/utils/util';
import { deleteAction, downFile, getAction, getFileAccessHttpUrl, postAction, putAction } from '@/api/manage'
import Vue from 'vue'
import { mapGetters } from 'vuex';
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { isURL } from '@/utils/validate'
export const JeecgBpmListMixin = {
  data() {
    return {
      // token header
      tokenHeader: {
        'Authorization': Vue.ls.get(ACCESS_TOKEN),
        'client-id': 'web',
        'user-id': Vue.ls.get('user_id') || ''
      },
      /* 查询条件-请不要在queryParam中声明非字符串值的属性 */
      queryParam: {
        permissionType: '1'
      },
      getDepartName: [], // 我的部门
      getTeamName: [], // 我的团队
      /* 数据源 */
      dataSource: [],
      /* 分页参数 */
      ipagination: {
        current: 1,
        pageSize: 10,
        pageSizeOptions: ['10', '20', '30', '50', '100', '200'],
        showTotal: (total, range) => {
          return range[0] + '-' + range[1] + ' 共' + total + '条'
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      /* 排序参数 */
      isorter: {
        column: 'createTime',
        order: 'desc'
      },
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 19 },
      },
      /* 筛选参数 */
      filters: {},
      /* table加载状态 */
      loading: false,
      /* table选中keys */
      selectedRowKeys: [],
      /* table选中records */
      selectionRows: [],
      /* 查询折叠 */
      toggleSearchStatus: false,
      /* 高级查询条件生效状态 */
      superQueryFlag: false,
      /* 高级查询条件 */
      superQueryParams: '',
      /** 高级查询拼接方式 */
      superQueryMatchType: 'and',
      flowCode: '',
      formUrl: '',
      path: '',
      formUrlMobile: '',
      formData: {
        isShowDeptLeader: ''
      },
      url: {
        startProcess: '/api/erpmng/act/process/extActProcess/startMutilProcess',
        getBizProcessNodeInfo: '/api/erpmng/act/process/extActProcessNode/getBizProcessNodeInfo',
        invalidProcess: '/api/erpmng/act/task/invalidBizProcess',
        queryFlowDataByCodeAndId: '/api/erpmng/act/process/extActFlowData/queryFlowDataByCodeAndId',
        checkNotify: '/api/erpmng/act/process/extActFlowData/checkNotify',
        getBizHisProcessNodeInfo: '/api/erpmng/act/process/extActProcessNode/getBizHisProcessNodeInfo'
      },
      bizTaskType: '0',
      iconStyle: { 'font-size': '18px', 'cursor': 'pointer' },
      colsettings: ':colsettings',
      doCount: 0,
      myCount: 0,
      exportLoading: false,
      domTable: null
    }
  },
  // mounted() {
  //   this.domTable = document.querySelector(".ant-table-body")
  //   this.domTable.addEventListener("mousedown", this.resize);
  //   this.domTable.addEventListener("mouseover", this.resize);
  //   this.domTable.addEventListener("mouseup", this.resize);
  // },
  // beforeDestroy() {
  //   this.domTable.removeEventListener("mousedown", this.resize);
  //   this.domTable.removeEventListener("mouseover", this.resize);
  //   this.domTable.removeEventListener("mouseup", this.resize);
  // },
  created() {
    // console.log('userInfo', this.userInfo()) userId: empId  username: username
    if (!this.disableMixinCreated) {
      console.log(' -- mixin created -- ')
      this.loadData();
      // 初始化字典配置 在自己页面定义
      this.initDictConfig();
      this.initColumns();
    }
  },
  computed: {
    /* 待处理数 */
    doTotal() {
      return this.doCount;
    },
    /* 我发起的 */
    myTotal() {
      return this.myCount;
    },
    draggableComponent: function() {
      return this.dragResizable(this.columns)
    },
    // 动态获取scrollX,防止数组固定列的大小变化
    scrollX() {
      return this.columns.reduce((preVal, curVal) => {
        return preVal + curVal.width
      }, 0)
    }
  },
  filters: {
    statusFilter(status) {
      const statusMap = {
        '1': '待提交',
        '2': '处理中',
        '3': '已完成',
        '4': '待提交',
        '5': '待审核'
      }
      return statusMap[status] || status
    },
    statusTypeFilter(type) {
      const statusTypeMap = {
        '1': 'success',
        '2': 'success',
        '3': 'success',
        '4': 'success',
        '5': 'success'
      }
      return statusTypeMap[type] || 'success'
    }
  },
  methods: {
    ...mapGetters(['userInfo']), // 用户信息
    // 点击获取单据来源
    handleDocumentSource () {
      if (this.queryParam.permissionType == 3) {
        // 本部门
        if (this.queryParam && this.queryParam.teamIds) {
          this.$delete(this.queryParam, 'teamIds')
        }
        this.getDepartName = []
        this.getTeamName = []
        var params1 = {
          username: this.userInfo().username
        }
        getAction('/api/erpmng/sys/sysDepart/getDepartByUserName', params1).then((res) => {
          if (res.success) {
            this.getDepartName = res.result
          } else {
            this.$message.warning('未查询到部门信息')
          }
      })
      } else if (this.queryParam.permissionType == 4) {
        // 本团队
        if (this.queryParam && this.queryParam.deptIds) {
          this.$delete(this.queryParam, 'deptIds')
        }
        this.getDepartName = []
        this.getTeamName = []
        var params2 = {
          userId: this.userInfo().empId
        }
        getAction('/api/erp/omc/teammanager/erpOmcTeamManager/getTeamByUserId', params2).then((res) => {
          if (res.success) {
            this.getTeamName = res.result
          } else {
            this.$message.warning('未查询到团队信息')
          }
        })
      } else {
        this.$delete(this.queryParam, 'teamIds')
        this.$delete(this.queryParam, 'deptIds')
        this.getDepartName = []
        this.getTeamName = []
      }
    },
    resize() {
      if (this.domTable.scrollWidth > this.domTable.clientWidth) {
        this.columns.forEach(val => {
          if (val.dataIndex == 'action') {
            val.fixed = 'right'
          }
        })
      } else {
        this.columns.forEach(val => {
          if (val.dataIndex == 'action') {
            delete val.fixed
          }
        })
      }
    },
    // 2022-12-06 工作流改造
    // 发起流程
    beginProcess(record) {
      this.$refs.processConfig.visible = true
      this.$refs.processConfig.formUrl = this.formUrl
      this.$refs.processConfig.formUrlMobile = this.formUrlMobile
      this.$refs.processConfig.flowCode = this.flowCode
      this.$refs.processConfig.edit(record, '', this.beanName)
    },
    // 流程审批结束禁用
    getCheckboxProps(record) {
      return {
        props: {
          disabled: record.bpmStatus !== '1'
        }
      }
    },
    allSearchReset() {
      this.qdrqRange = null
      this.queryParam = {};
      this.bizTaskType = null
      this.loadData(1);
    },
    async loadData(arg) {
      if (!this.url.list) {
        this.$message.error('请设置url.list属性!')
        return
      }
      // 加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1;
      }
      var params = this.getQueryParams();// 查询条件
      params.pageUrl = this.$route.path
      this.loading = true;
      let res = await getAction(this.url.list, params)
      this.loading = false;
      if (res.success) {
        this.dataSource = res.result ? res.result.records : []
        this.ipagination.total = res.result ? res.result.total : ''
        // 判断是否当前页没有数据且不为第一页
        if (this.dataSource.length == 0 && this.ipagination.current != 1) {
          this.ipagination.current = this.ipagination.current - 1
          this.loadData(this.ipagination.current - 1);
        }

        const data = [...this.dataSource];
        if (this.queryParam.bizTaskType == '1') {
          for (var i = 0; i < data.length; i++) {
            // item.taskUrge = false;
            var item = data[i];
            var params = { flowCode: this.flowCode, dataId: item.id };// 查询条件
            let res2 = await getAction(this.url.checkNotify, params);
            if (res2.result) {
              item.taskUrge = true;
            }
          }
        }
        this.dataSource = data;
      } else {
        this.$message.warning(res.message)
      }
      this.bizCount();
    },
    // 新增流程取消关闭弹窗刷新页面
    handleClose () {
      this.$refs.modalForm.handleCancel()
      this.loadData();
    },
    initDictConfig() {
      console.log('--这是一个假的方法!')
    },
    handleSuperQuery(arg) {
      // 高级查询方法
      if (!arg) {
        this.superQueryParams = ''
        this.superQueryFlag = false
      } else {
        this.superQueryFlag = true
        this.superQueryParams = JSON.stringify(arg)
        this.superQueryMatchType = matchType
      }
      this.loadData(1)
    },
    getQueryParams() {
      // 获取查询条件
      let sqp = {}
      if (this.superQueryParams) {
        sqp['superQueryParams'] = encodeURI(this.superQueryParams)
        sqp['superQueryMatchType'] = this.superQueryMatchType
      }
      var param = Object.assign(sqp, this.queryParam, this.isorter, this.filters);
      param.field = this.getQueryField();
      param.pageNo = this.ipagination.current;
      param.pageSize = this.ipagination.pageSize;

      // 增加flowCode
      param.flowCode = this.flowCode;
      return filterObj(param);
    },
    getQueryField() {
      // TODO 字段权限控制
      var str = 'id,';
      this.columns.forEach(function (value) {
        str += ',' + value.dataIndex;
      });
      return str;
    },

    onSelectChange(selectedRowKeys, selectionRows) {
      this.selectedRowKeys = selectedRowKeys;
      this.selectionRows = selectionRows;
    },
    onClearSelected() {
      this.selectedRowKeys = [];
      this.selectionRows = [];
    },
    searchQuery() {
      this.onClearSelected();
      this.loadData(1);
    },
    superQuery() {
      this.$refs.superQueryModal.show();
    },
    searchReset() {
      this.onClearSelected();
      if (this.bizTaskType) {
        this.queryParam = { bizTaskType: this.bizTaskType, permissionType: '1' };
      }
      this.loadData(1);
    },
    batchDel: function () {
      if (!this.url.deleteBatch) {
        this.$message.error('请设置url.deleteBatch属性!')
        return
      }
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('请选择一条记录！');
      } else {
        var ids = '';
        for (var a = 0; a < this.selectedRowKeys.length; a++) {
          ids += this.selectedRowKeys[a] + ',';
        }
        var that = this;
        this.$confirm({
          title: '确认删除',
          content: '是否删除选中数据?',
          onOk: function () {
            deleteAction(that.url.deleteBatch, { ids: ids }).then((res) => {
              if (res.success) {
                that.$message.success(res.message);
                that.loadData();
                that.onClearSelected();
              } else {
                that.$message.warning(res.message);
              }
            });
          }
        });
      }
    },
    handleDelete: function (id) {
      if (!this.url.delete) {
        this.$message.error('请设置url.delete属性!')
        return
      }
      var that = this;
      deleteAction(that.url.delete, { id: id }).then((res) => {
        if (res.success) {
          that.$message.success(res.message);
          that.loadData();
        } else {
          that.$message.warning(res.message);
        }
      });
    },
    handleEdit: function (record) {
      this.$refs.modalForm.edit(record);
      this.$refs.modalForm.title = '编辑';
      this.$refs.modalForm.disableSubmit = false;
    },
    handleAdd: function () {
      this.$refs.modalForm.add();
      this.$refs.modalForm.title = '新增';
      this.$refs.modalForm.disableSubmit = false;
    },
    handleTableChange(pagination, filters, sorter) {
      // 分页、排序、筛选变化时触发
      this.filters = {}
      if (Object.keys(filters).length > 0) {
        for (let key in filters) {
          let value = filters[key].join(',')
          if (value) {
            if (key.indexOf('_dictText') != -1) {
              key = key.substring(0, key.indexOf('_dictText'))
            }
            this.filters[key] = value
          }
        }
      }
      // TODO 筛选
      if (Object.keys(sorter).length > 0) {
        this.isorter.column = sorter.field;
        this.isorter.order = sorter.order == 'ascend' ? 'asc' : 'desc'
      }
      this.ipagination = pagination;
      this.loadData();
    },

    /**
     * 批量导出word
     *
     * @param fileName
     */
    batchExportWord(fileName) {
      this.batchExportLoading = true;
      let param = this.getQueryParams()
      if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
        param['selections'] = this.selectedRowKeys.join(',')
      }
      console.log('导出参数', param)
      downFile(this.url.batchExportWord, param).then(data => {
        if (!data) {
          this.$message.warning('文件下载失败')
          return
        }
        let url = window.URL.createObjectURL(
          new Blob([data], {
            type: 'application/vnd.ms-excel'
          })
        )
        let link = document.createElement('a')
        link.style.display = 'none'
        link.href = url
        link.setAttribute('download', fileName + '_' + this.setNowFormatDate() + '.zip')
        document.body.appendChild(link)
        link.click()
        document.body.removeChild(link) // 下载完成移除元素
        window.URL.revokeObjectURL(url) // 释放掉blob对象
        this.batchExportLoading = false;
      })
    },
    // 获取当前时间yyyy-MM-dd HH:MM:SS
    setNowFormatDate() {
      let date = new Date();
      let month = (date.getMonth() + 1).toString().padStart(2, '0');
      let strDate = date.getDate().toString().padStart(2, '0');
      // 时间格式yyyy-MM-dd HH:MM:SS
      return `${date.getFullYear()}-${month}-${strDate}`;
    },

    handleToggleSearch() {
      this.toggleSearchStatus = !this.toggleSearchStatus;
    },
    handleSuccess() {
      this.loadData();
      this.onClearSelected();
      this.$refs.modalForm.handleCancel()
    },
    modalFormOk(type = '', record = {}) {
      if (type && record && type == 'submit') {
        this.beginProcess(record)
      } else {
        // 新增/修改 成功时，重载列表
        this.loadData();
      }
    },
    modalFormClose () {
      this.loadData();
    },
    handleDetail: function (record) {
      const _path = this.$route.path
      console.log('path', _path)
      var a = `${_path}Detail/${record.id}`
      // if (_path === '/erp/omc/contractmanager/ErpOmcContractBorrowManagerList') {
      //   return false
      // }
      this.$router.push({
        path: `${_path}Detail/${record.id}`
      })
    },
    /* 导出 */
    handleExportXls2() {
      let paramsStr = encodeURI(JSON.stringify(this.getQueryParams()));
      let url = `${window._CONFIG['domianURL']}/${this.url.exportXlsUrl}?paramsStr=${paramsStr}`;
      window.location.href = url;
    },
    handleExportXls(fileName) {
      this.exportLoading = true;
      if (!fileName || typeof fileName !== 'string') {
        fileName = '导出文件'
      }
      let param = this.getQueryParams();
      param.pageUrl = this.$route.path
      if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
        param.selections = this.selectedRowKeys.join(',')
        // if(this.rowSpanPagination){

        //   param.selections = this.selectionRows.map(rr=>{
        //     return rr.id
        //   })
        //   let newArr = param.selections.filter(function(item,index){
        //     return param.selections.indexOf(item) === index;  // 因为indexOf 只能查找到第一个
        //   })
        //   param.selections = String(newArr)

        // }else{
        //   param.selections = this.selectedRowKeys.join(',')
        // }
      }
      downFile(this.url.exportXlsUrl, param).then((data) => {
        if (!data) {
          this.$message.warning('文件下载失败')
          return
        }
        if (typeof window.navigator.msSaveBlob !== 'undefined') {
          window.navigator.msSaveBlob(new Blob([data]), fileName + '.xls')
        } else {
          let url = window.URL.createObjectURL(new Blob([data]))
          let link = document.createElement('a')
          link.style.display = 'none'
          link.href = url
          link.setAttribute('download', fileName + '.xls')
          document.body.appendChild(link)
          link.click()
          document.body.removeChild(link); // 下载完成移除元素
          window.URL.revokeObjectURL(url); // 释放掉blob对象
        }
      }).finally(() => {
        this.exportLoading = false;
      })
    },
    /* 导入 */
    handleImportExcel(info) {
      if (info.file.status !== 'uploading') {
        console.log(info.file, info.fileList);
      }
      if (info.file.status === 'done') {
        if (info.file.response.success) {
          this.$message.success(`${info.file.name} 文件上传成功`);
          this.loadData();
        } else {
          this.$message.error(`${info.file.name} ${info.file.response.message}.`);
        }
      } else if (info.file.status === 'error') {
        this.$message.error(`文件上传失败: ${info.file.msg} `);
      }
    },
    /* 图片预览 */
    getImgView(text) {
      if (text && text.indexOf(',') > 0) {
        text = text.substring(0, text.indexOf(','))
      }
      return getFileAccessHttpUrl(text)
    },
    /* 文件下载 */
    // update--autor:lvdandan-----date:20200630------for：修改下载文件方法名uploadFile改为downloadFile------
    downloadFile(text) {
      if (!text) {
        this.$message.warning('无可下载文件')
        return;
      }
      if (text.indexOf(',') > 0) {
        text = text.substring(0, text.indexOf(','))
      }
      let url = getFileAccessHttpUrl(text)
      window.open(url);
    },

    onBizTaskTypeChange(e) {
      this.queryParam.bizTaskType = e.target.value;
      this.handleSuperQuery();
    },
    startProcess: function (record) {
      var that = this;
      this.$confirm({
        title: '提示',
        content: '确认提交流程吗?',
        onOk: function () {
          var param = {
            flowCode: that.flowCode,
            id: record.id,
            formUrl: that.formUrl,
            formUrlMobile: that.formUrlMobile
          }
          postAction(that.url.startProcess, param).then((res) => {
            if (res.success) {
              that.$message.success(res.message);
              that.loadData();
              that.onClearSelected();
            } else {
              that.$message.warning(res.message);
            }
          }).catch((e) => {
            this.$message.warning('不识别的请求!');
          });
        }
      });
    },
    confirmOk: function (record) {
      var that = this;
      this.$confirm({
        title: '提示',
        content: '确认提交?',
        onOk: function () {
          var param = {
            flowCode: that.flowCode,
            id: record.id,
            formUrl: that.formUrl,
            formUrlMobile: that.formUrlMobile
          }
          postAction(that.url.startProcess, param).then((res) => {
            if (res.success) {
              that.$message.success(res.message);
              that.loadData();
              that.onClearSelected();
            } else {
              that.$message.warning(res.message);
            }
          }).catch((e) => {
            this.$message.warning('不识别的请求!');
          });
        }
      });
    },
    handlePreviewPic: function (record) {
      var flowCode = this.flowCode;
      var dataId = record.id;
      this.$refs.extActProcessInstPicModal.preview(flowCode, dataId);
      this.$refs.extActProcessInstPicModal.title = '流程图';
    },
    handleProcess(record) {
      this.getBizProcessNodeInfo(record);
    },
    handleOk() {
      this.loadData();
      this.onClearSelected();
    },
    getBizProcessNodeInfo(record) {
      // debugger;
      var params = { flowCode: this.flowCode, dataId: record.id };// 查询条件
      getAction(this.url.getBizProcessNodeInfo, params).then((res) => {
        if (res.success) {
          var data = {
            dataId: res.result.dataId,
            taskId: res.result.taskId,
            taskDefKey: res.result.taskDefKey,
            procInsId: res.result.procInsId,
            tableName: res.result.tableName,
            permissionList: res.result.permissionList,
            bizTaskList: res.result.bizTaskList,
            vars: res.result.records
          }
          this.formData = data;
          let tempFormUrl = res.result.formUrl;
          // 节点配置表单URL，VUE组件类型对应的拓展参数
          if (tempFormUrl && tempFormUrl.indexOf('?') != -1 && !isURL(tempFormUrl) && tempFormUrl.indexOf('{{DOMAIN_URL}}') == -1) {
            tempFormUrl = res.result.formUrl.split('?')[0];
            // update--begin--autor:taoyan-----date:20200729------for：支持新版代码生成器，简易实现表单带button编辑效果------
            let qv = getQueryVariable(res.result.formUrl)
            this.formData.extendUrlParams = qv
            if (qv.edit == 1) {
              this.formData['disabled'] = false
            }
            // update--end--autor:taoyan-----date:20200729------for：支持新版代码生成器，简易实现表单带button编辑效果------
          }
          this.path = tempFormUrl;
          this.$refs.taskDealModal.deal(data);
          this.$refs.taskDealModal.title = '流程办理';
        }
      })
    },
    // 流程作废
    invalidProcess(record) {
      var that = this;
      var params = { flowCode: this.flowCode, dataId: record.id };// 查询条件
      putAction(that.url.invalidProcess, params).then((res) => {
        if (res.success) {
          that.$message.success(res.message);
          that.loadData();
        } else {
          that.$message.warning(res.message);
          that.loadData();
        }
      })
    },
    handleTrack(record) {
      var params = { flowCode: this.flowCode, dataId: record.id };// 查询条件
      this.$refs.bpmProcessTrackModal.handleTrack(params);
      this.$refs.bpmProcessTrackModal.title = '审批跟踪记录';
    },
    showBtn(bpmStatus) {
      return showDealBtn(bpmStatus);
    },
    // 催办
    taskNotify(flowCode, dataId) {
      var params = { flowCode: flowCode, dataId: dataId };// 查询条件
      getAction(this.url.queryFlowDataByCodeAndId, params).then((res) => {
        if (res.success) {
          this.$refs.taskNotifyModal.notify(res.result.processInstId);
          this.$refs.taskNotifyModal.title = '催办提醒';
        }
      })
    },
    // 提醒我的
    taskNotifyMe(flowCode, dataId) {
      var params = { flowCode: flowCode, dataId: dataId };// 查询条件
      getAction(this.url.queryFlowDataByCodeAndId, params).then((res) => {
        if (res.success) {
          this.$refs.taskNotifyMeModal.notify(res.result.processInstId);
          this.$refs.taskNotifyMeModal.title = '催办提醒';
        }
      })
    },
    initColumns() {
      // 权限过滤（列权限控制时打开，修改第二个参数为授权码前缀）
      // this.defColumns = colAuthFilter(this.defColumns,'testdemo:');
      if (this.defColumns) {
        var key = this.$route.name + this.colsettings
        let colSettings = Vue.ls.get(key)
        if (colSettings == null || colSettings == undefined) {
          let allSettingColumns = []
          this.defColumns.forEach(function (item, i, array) {
            allSettingColumns.push(item.dataIndex)
          })
          this.settingColumns = allSettingColumns
          this.columns = this.defColumns
        } else {
          Vue.ls.set(key, colSettings, 7 * 24 * 60 * 60 * 1000)
          this.settingColumns = colSettings
          const cols = this.defColumns.filter(item => {
            if (item.key == 'rowIndex' || item.dataIndex == 'action') {
              return true
            }
            if (colSettings.includes(item.dataIndex)) {
              return true
            }
            return false
          })
          this.columns = cols
        }
      }
    },
    // 列设置更改事件
    onColSettingsChange(checkedValues) {
      var key = this.$route.name + this.colsettings
      Vue.ls.set(key, checkedValues, 7 * 24 * 60 * 60 * 1000)
      this.settingColumns = checkedValues
      const cols = this.defColumns.filter(item => {
        if (item.key == 'rowIndex' || item.dataIndex == 'action') {
          return true
        }
        if (this.settingColumns.includes(item.dataIndex)) {
          return true
        }
        return false
      })
      this.columns = cols
    },
    // table 双击查看详情
    customRow(record) {
      return {
        on: {
          // 事件
          dblclick: event => {
            this.handleDetail(record)
          }
        }
      }
    },
    // 工作流标签切换（0所有，1待我处理，2我发起的）
    handleChangeTabs(e) {
      if (e != 0) {
        this.$set(this.queryParam, 'bizTaskType', e)
        this.handleSuperQuery();
      } else {
        this.$set(this.queryParam, 'bizTaskType', undefined)
        this.handleSuperQuery();
      }
    },
    // hanyu 查看页面看工作流记录
    viewTrack(params) {
      getAction(this.url.getBizHisProcessNodeInfo, params).then((res) => {
        if (res.success) {
          var data = {
            dataId: res.result.dataId,
            procInsId: res.result.procInsId,
            tableName: res.result.tableName,
            vars: res.result.records
          }
          this.formData = data;
          this.path = res.result.formUrl;
          if (this.$refs.bizHisTask) {
            this.$refs.bizHisTask.getHisProcessTaskTransInfo(this.formData);
          }
          
        }
      })
    },
    // hanyu 根据id查询待办数和我发起的数量
    bizCountById(id) {
      this.doCount = 0;
      this.myCount = 0;
      let params1 = { id: id, bizTaskType: '1', flowCode: this.flowCode }
      getAction(this.url.bizCount, params1).then((res) => {
        if (res.success) {
          this.doCount = res.result || 0;
        }
      })
      let params2 = { id: id, bizTaskType: '2', flowCode: this.flowCode }
      getAction(this.url.bizCount, params2).then((res) => {
        if (res.success) {
          this.myCount = res.result || 0;
        }
      })
    },
    // hanyu 查询待办数和我发起的数量
    bizCount() {
      this.doCount = 0;
      this.myCount = 0;
      let params1 = { bizTaskType: '1', flowCode: this.flowCode }
      getAction(this.url.bizCount, params1).then((res) => {
        if (res.success) {
          this.doCount = res.result || 0;
        }
      })
      /* let params2 = {bizTaskType: '2', flowCode: this.flowCode}
      getAction(this.url.bizCount, params2).then((res) => {
        if (res.success) {
          this.myCount = res.result || 0;
        }
      }) */
    }
  }

}

// 获取URL上参数
function getQueryVariable(url) {
  if (!url) return

  var t; var n; var r; var i = url.split('?')[1]; var s = {};
  t = i.split('&'),
    r = null,
    n = null;
  for (var o in t) {
    var u = t[o].indexOf('=');
    u !== -1 && (r = t[o].substr(0, u),
      n = t[o].substr(u + 1),
      s[r] = n)
  }
  return s
}
